package com.itlxd.result;

import com.itlxd.global.HttpCode;
import com.itlxd.global.SysConstants;
import com.itlxd.global.SysMessages;
import lombok.Data;

import java.io.Serializable;
import java.lang.reflect.Type;

/**
 * @author: lixiaodong
 **/
@Data
public class ResultVO<T> implements Serializable {

    private Integer code;

    private String message;

    private T data;


    public static <T> ResultVO<T> success(Integer code, T data, String message) {
        return new ResultVO(code, data, message);
    }

    public static <T> ResultVO<T> success( T data, String message) {
        return new ResultVO(HttpCode.SUCCESS, data, message);
    }


    public static <T> ResultVO<T> success( String message) {
        return new ResultVO( HttpCode.SUCCESS,message);
    }

    public static <T> ResultVO<T> error(Integer code, String message) {
        return new ResultVO<>(code, message);
    }

    public static <T> ResultVO<T> error(String message) {
        return new ResultVO(HttpCode.ERROR,message);
    }

    private ResultVO(Integer code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    private ResultVO(Integer code, String message) {
        this.code = code;
        this.message = message;
        this.data = null;
    }


}
